﻿using codeparser.net.v2.Exceptions;

using System;
using System.Collections.ObjectModel;

namespace codeparser.net.v2.SyntaxHighlighter
{
    /// <summary>
    /// Represents the base class for syntax highlighters.
    /// </summary>
    public abstract class SyntaxHighlighterBase
    {
        /// <summary>
        /// Contains the language.
        /// </summary>
        private Language _language;

        /// <summary>
        /// Gets or sets the language.
        /// </summary>
        /// <value>The language.</value>
        public Language Language
        {
            get
            {
                return this._language;
            }

            set
            {
                if (!this.SupportedLanguages.Contains(value))
                {
                    throw new LanguageNotSupportedException("The specified language is not supported by this syntax highlighter");
                }

                this._language = value;
            }
        }

        /// <summary>
        /// Gets a list of languages supported by this syntax highlighter.
        /// </summary>
        /// <value>The list of languages.</value>
        public abstract Collection<Language> SupportedLanguages
        {
            get;
        }

        /// <summary>
        /// Highlights the specified text.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <returns>The highlighted text.</returns>
        public abstract string Highlight(string text);
    }
}